﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace JWUX.Supermarket.Model
{
    [DataContract]
    public class RequestInfo : IJsonSerializable
    {
        #region 成员

        private List<MaterialItem> _materials;

        #endregion

        #region 构造和方法

        public RequestInfo()
        {
            RequestOn = DateTime.Now;
        }

        #endregion

        #region 属性

        /// <summary>
        /// 申请编号
        /// </summary>
        [DataMember]
        public decimal? Id
        {
            get;
            set;
        }

        /// <summary>
        /// 出库单据号
        /// </summary>
        [DataMember]
        public string BillId
        {
            get;
            set;
        }

        /// <summary>
        /// 申请者ID
        /// </summary>
        public decimal RequestorId
        {
            get;
            set;
        }

        /// <summary>
        /// 申请者Fullname
        /// </summary>
        public string Requestor
        {
            set;
            get;
        }

        [DataMember]
        public DateTime RequestOn
        {
            get;
            private set;
        }

        [DataMember]
        public int LocationId
        {
            get;
            set;
        }

        /// <summary>
        /// 配料时间
        /// </summary>
        [DataMember]
        public int RequireTime
        {
            get;
            set;
        }

        /// <summary>
        /// Model编号
        /// </summary>
        [DataMember]
        public decimal ModelId
        {
            get;
            set;
        }

        /// <summary>
        /// 需求数量
        /// </summary>
        [DataMember]
        public int Number
        {
            get;
            set;
        }

        public DateTime CreatedOn
        {
            get;
            private set;
        }

        public int? CreatedById
        {
            get;
            set;
        }

        public string CreatedBy
        {
            set;
            get;
        }

        public bool IsCancelled
        {
            get;
            set;
        }

        public string CancelCause
        {
            get;
            set;
        }

        public bool IsAvailable
        {
            get;
            set;
        }

        /// <summary>
        /// 物料列表
        /// </summary>
        [DataMember]
        public List<MaterialItem> Materials
        {
            get
            {
                if (_materials == null)
                {
                    _materials = new List<MaterialItem>();
                }
                return _materials;
            }
            set { _materials = value; }
        }

        #endregion
    }
}
